<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for javascripts/explorev2/reducers/exploreReducer.js</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../../../prettify.css" />
    <link rel="stylesheet" href="../../../base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(../../../sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="../../../index.html">All files</a> / <a href="index.html">javascripts/explorev2/reducers</a> exploreReducer.js
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">35.42% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>17/48</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">16.67% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>2/12</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">11.11% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>3/27</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">34.04% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>16/47</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">/* eslint camelcase: 0 */
import { getControlsState, getFormDataFromControls } from '../stores/store';
import * as actions from '../actions/exploreActions';
import { now } from '../../modules/dates';
&nbsp;
export const exploreReducer = function (state, action) {
  const <span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" >actionHandlers = {</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
    [actions.TOGGLE_FAVE_STAR]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { isStarred: action.isStarred });</span>
    },
&nbsp;
    [actions.FETCH_DATASOURCE_STARTED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { isDatasourceMetaLoading: true });</span>
    },
&nbsp;
    [actions.FETCH_DATASOURCE_SUCCEEDED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { isDatasourceMetaLoading: false });</span>
    },
&nbsp;
    [actions.FETCH_DATASOURCE_FAILED]() {
      // todo(alanna) handle failure/error state
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state,</span>
        {
          isDatasourceMetaLoading: false,
          controlPanelAlert: action.error,
        });
    },
    [actions.SET_DATASOURCE]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { datasource: action.datasource });</span>
    },
    [actions.FETCH_DATASOURCES_STARTED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { isDatasourcesLoading: true });</span>
    },
&nbsp;
    [actions.FETCH_DATASOURCES_SUCCEEDED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { isDatasourcesLoading: false });</span>
    },
&nbsp;
    [actions.FETCH_DATASOURCES_FAILED]() {
      // todo(alanna) handle failure/error state
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state,</span>
        {
          isDatasourcesLoading: false,
          controlPanelAlert: action.error,
        });
    },
    [actions.SET_DATASOURCES]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { datasources: action.datasources });</span>
    },
    [actions.REMOVE_CONTROL_PANEL_ALERT]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { controlPanelAlert: null });</span>
    },
    [actions.FETCH_DASHBOARDS_SUCCEEDED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { dashboards: action.choices });</span>
    },
&nbsp;
    [actions.FETCH_DASHBOARDS_FAILED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state,</span>
        { saveModalAlert: `fetching dashboards failed for ${action.userId}` });
    },
    [actions.SET_FIELD_VALUE]() {
      const controls = Object.assign({}, state.controls);
      const control = Object.assign({}, controls[action.controlName]);
      control.value = action.value;
      control.validationErrors = action.validationErrors;
      controls[action.controlName] = control;
      const changes = { controls };
      <span class="missing-if-branch" title="else path not taken" >E</span>if (control.renderTrigger) {
        changes.triggerRender = true;
      }
      return Object.assign({}, state, changes);
    },
    [actions.CHART_UPDATE_SUCCEEDED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign(</span>
        {},
        state,
        {
          chartStatus: 'success',
          queryResponse: action.queryResponse,
        }
      );
    },
    [actions.CHART_UPDATE_STARTED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state,</span>
        {
          chartStatus: 'loading',
          chartUpdateEndTime: null,
          chartUpdateStartTime: now(),
          triggerQuery: false,
          queryRequest: action.queryRequest,
          latestQueryFormData: getFormDataFromControls(state.controls),
        });
    },
    [actions.CHART_UPDATE_STOPPED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state,</span>
        {
          chartStatus: 'stopped',
          chartAlert: 'Updating chart was stopped',
        });
    },
    [actions.CHART_RENDERING_FAILED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, {</span>
        chartStatus: 'failed',
        chartAlert: 'An error occurred while rendering the visualization: ' + action.error,
      });
    },
    [actions.TRIGGER_QUERY]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, {</span>
        triggerQuery: true,
      });
    },
    [actions.CHART_UPDATE_FAILED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, {</span>
        chartStatus: 'failed',
        chartAlert: action.queryResponse ? action.queryResponse.error : 'Network error.',
        chartUpdateEndTime: now(),
        queryResponse: action.queryResponse,
      });
    },
    [actions.UPDATE_CHART_STATUS]() {
      c</span>onst newState = <span class="cstat-no" title="statement not covered" >Object.assign({}, state, { chartStatus: action.status });
<span class="cstat-no" title="statement not covered" >      if (action.status === 'success' || action.status === 'failed') {</span>
<span class="cstat-no" title="statement not covered" >        newState.chartUpdateEndTime = now();</span>
      }
<span class="cstat-no" title="statement not covered" >      return newState;</span>
    },
    [actions.REMOVE_CHART_ALERT]() {
<span class="cstat-no" title="statement not covered" >      if (state.chartAlert !== null) {</span>
<span class="cstat-no" title="statement not covered" >        return Object.assign({}, state, { chartAlert: null });</span>
      }
<span class="cstat-no" title="statement not covered" >      return state;</span>
    },
    [actions.SAVE_SLICE_FAILED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { saveModalAlert: 'Failed to save slice' });</span>
    },
    [actions.REMOVE_SAVE_MODAL_ALERT]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { saveModalAlert: null });</span>
    },
    [actions.RESET_FIELDS]() {
      c</span>onst controls = <span class="cstat-no" title="statement not covered" >getControlsState(state, getFormDataFromControls(state.controls));
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { controls });</span>
    },
    [actions.RENDER_TRIGGERED]() {
<span class="cstat-no" title="statement not covered" >      return Object.assign({}, state, { triggerRender: false });</span>
    },
  };
  <span class="missing-if-branch" title="else path not taken" >E</span>if (action.type in actionHandlers) {
    return actionHandlers[action.type]();
  }
<span class="cstat-no" title="statement not covered" >  return state;</span>
};
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Apr 11 2017 20:15:55 GMT-0700 (PDT)
</div>
</div>
<script src="../../../prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="../../../sorter.js"></script>
</body>
</html>
